<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
    var students =[
        {"name":"cheng",count:30},
        {"name":"li",count:12},
        {"name":"zhang",count:14}
    ]
    // 升序
    function up(arr,value){
        var res = arr.sort((a,b)=>{
            return a[value]-b[value];
        })
        return res;
    }
    // 降序
    function down (arr,value){
        var res = arr.sort((a,b)=>{
            return b[value]-a[value];
        })
        return res;
    }
    console.log(...up(students,"count"))
    console.log(...down(students,"count"))
</script>
</body>
</html>